package my_stream;

import java.util.ArrayList;

public class demo1 {
    public static void main(String[] args) {
        ArrayList<String> list1 = new ArrayList<>();
        list1.add("a1");
        list1.add("acdvs");
        list1.add("vbh");
        list1.add("111");
        list1.add("ank");

        list1.stream().filter(name -> name.startsWith("a")).
                filter(name -> name.length()==3).forEach(name -> System.out.println(name));

        //挑选出开头为a的
        ArrayList<String> list2 = new ArrayList<>();
        for(String s : list1){
            if(s.startsWith("a")){
                list2.add(s);
            }
        }

        ArrayList<String> list3 = new ArrayList<>();
        for(String s : list2){
            if(s.length() == 3){
                list3.add(s);
            }
        }

        System.out.println(list3);
    }
}
